using System;
using AjaxPro;

internal class Tag
{
    private readonly String description;
    private readonly DateTime dateTimeCreated;

    public Tag(String description, DateTime dateTimeCreated)
    {
        this.description = description;
        this.dateTimeCreated = dateTimeCreated;
    }

    public String Description {
        get { return description; }
    }

    public IJavaScriptObject ToJavaScript()
    {
        JavaScriptObject jso = new JavaScriptObject();
        jso.Add("description", new JavaScriptString(Description));
        TimeSpan elapsedSince_1970_1_1 = dateTimeCreated.ToUniversalTime()
            - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
        jso.Add("dateTimeCreated", new JavaScriptSource(
            String.Format("new Date({0})",
                Convert.ToInt64(elapsedSince_1970_1_1.TotalMilliseconds))));
        return jso;
    }
}